package com.scpii.api.service.content.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.scpii.api.domain.content.Comments;
import com.scpii.api.domain.content.Resources;
import com.scpii.api.persistence.content.CommentsMapper;
import com.scpii.api.persistence.content.ResourcesMapper;
import com.scpii.api.service.content.CommentsService;

@Service
public class CommentServiceImpl implements CommentsService {

	@Resource
	private CommentsMapper commentsMapper;

	@Resource
	private ResourcesMapper resourcesMapper;

	@Override
	public List<Comments> selectBySelective(Comments comments) {
		return commentsMapper.selectBySelective(comments);
	}

	@Override
	public void insertComments(Comments record) {
		commentsMapper.insertSelective(record);
		List<Resources> resources = record.getResources();
		for (Resources res : resources) {
			res.setTargetId(record.getId());
			resourcesMapper.insertSelective(res);
		}
	}
}
